# Maintainer: <matheus-catarino@hotmail.com>

_realname=zeal
_builddir=build
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.6.1
pkgrel=2
pkgdesc="Offline documentation browser inspired by Dash (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/zealdocs/${_realname}"
license=("GPL3")
depends=("${MINGW_PACKAGE_PREFIX}-libarchive"
         "${MINGW_PACKAGE_PREFIX}-qt5"
         "${MINGW_PACKAGE_PREFIX}-qtwebkit")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-extra-cmake-modules")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/zealdocs/${_realname}/archive/v${pkgver}.tar.gz")
sha256sums=('095c08f9903071849d5c79878abd48237ce1615f16d324afff1873ab6b5f0026')

build() {
  [[ -d "${srcdir}"/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DZEAL_PORTABLE_BUILD=OFF \
    ../${_realname}-${pkgver}
  
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  install -Dm755 bin/zeal.exe ${pkgdir}${MINGW_PREFIX}/bin/zeal.exe
  install -Dm644 ${srcdir}/${_realname}-${pkgver}/COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
